package com.woniu.finance.contorller;


import com.woniu.aop.OperationLogAnnotation;
import com.woniu.finance.entity.RequestParam;
import com.woniu.finance.entity.Tender;
import com.woniu.finance.entity.vo.TendFullVO;
import com.woniu.finance.entity.vo.TenderPlatformAuditVO;
import com.woniu.finance.service.ITenderService;
import com.woniu.util.utils.HttpResult;
import com.woniu.util.utils.RequestResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 投标表 前端控制器
 * </p>
 *
 * @author 杨鹏
 * @since 2023-04-25
 */
@RestController
@RequestMapping("/finance/tender")
@Slf4j
public class TenderController {

    @Autowired
    private ITenderService tenderService;

    @PostMapping("/saveTender")
    @OperationLogAnnotation(operModul = "融资企业-标的表",operType = "新增",operDesc = "新增标的表")//操作日志注解
    public HttpResult<?> saveTender(@RequestBody Tender tender){
        return tenderService.saveTender(tender);
    }

    @RequestMapping("/removeTender")
    @OperationLogAnnotation(operModul = "融资企业-标的表",operType = "删除",operDesc = "删除标的表")//操作日志注解
    public HttpResult<?> removeTender(Integer id){
        return tenderService.removeTender(id);
    }

    @PostMapping("/modifyTender")
    @OperationLogAnnotation(operModul = "融资企业-标的表",operType = "修改",operDesc = "修改标的表")//操作日志注解
    public HttpResult<?> modifyTender(@RequestBody Tender tender){
        return tenderService.modifyTender(tender);
    }

    @RequestMapping("/findAllTender")
    @OperationLogAnnotation(operModul = "融资企业-标的表",operType = "查询",operDesc = "查询所有标的表")//操作日志注解
    public HttpResult<?> findAllTender(){
        return tenderService.findAllTender();
    }

    @RequestMapping("/findTenderById")
    @OperationLogAnnotation(operModul = "融资企业-标的表",operType = "查询",operDesc = "根据id查询标的表")//操作日志注解
    public HttpResult<?> findTenderById(Integer id){
        return tenderService.findTenderById(id);
    }

    @RequestMapping("/findTenderByAnnualizedInterestRate1")
    @OperationLogAnnotation(operModul = "融资企业-标的表",operType = "查询",operDesc = "根据利率1-3查询标的表")//操作日志注解
    public HttpResult<?> findTenderByAnnualizedInterestRate1(Double annualizedInterestRate){
        return tenderService.findTenderByAnnualizedInterestRate1(annualizedInterestRate);
    }

    @RequestMapping("/findTenderByAnnualizedInterestRate2")
    @OperationLogAnnotation(operModul = "融资企业-标的表",operType = "查询",operDesc = "根据利率3-5查询标的表")//操作日志注解
    public HttpResult<?> findTenderByAnnualizedInterestRate2(Double annualizedInterestRate){
        return tenderService.findTenderByAnnualizedInterestRate2(annualizedInterestRate);
    }

    @RequestMapping("/findTenderByAnnualizedInterestRate3")
    @OperationLogAnnotation(operModul = "融资企业-标的表",operType = "查询",operDesc = "根据利率5-7查询标的表")//操作日志注解
    public HttpResult<?> findTenderByAnnualizedInterestRate3(Double annualizedInterestRate){
        return tenderService.findTenderByAnnualizedInterestRate3(annualizedInterestRate);
    }

    @RequestMapping("/queryTenderInfoByPage")
    @OperationLogAnnotation(operModul = "融资企业-查询标的的功能", operType = "查询", operDesc = "查询标的")//操作日志注释
//    @ApiOperation(value = "查询标的", notes = "这是用来查询标的的功能")//基于swagger 用于扩展操作描述
    public HttpResult<?> queryTenderInfoByPage(@RequestBody RequestParam<Tender> param){
        return tenderService.queryTenderInfoByPage(param);
    }

    /**
     * 查看标满的信息
     * @param parm
     * @return
     */
    @PostMapping("/fulllist")
    public HttpResult queryFullTenderService(@RequestBody  RequestParam<TendFullVO> parm){
        return tenderService.queryTendfullByPage(parm);
    }

    /**
     * 放款，生成放款记录
     * @param list
     * @return
     */
    @PostMapping("/goaheadtend")
    public HttpResult goAheadTender(@RequestBody List<TendFullVO> list){
        return tenderService.insertLoadAndChangeTend(list);
    }

    @PostMapping("/platformAuditTender")
    public HttpResult queryTendPlatformAudit(@RequestBody RequestResult<TenderPlatformAuditVO> param){

        return tenderService.queryTendPlatformAudit(param);
    }
}
